#ifndef _MESSAGE_HPP_
#define _MESSAGE_HPP__

#include <cstdio>
#include <cstdlib>
#include <cstring>

class Message
{
public:
    enum{head_length = 4};
    enum{max_body_length = 512};

    // Properties
    const char* data() const {return m_data;}
    char* data() { return m_data;}
    std::size_t length() const { return head_length + m_body_length;}
    const char* body() const { return m_data + head_length;}
    char* body() { return m_data + head_length;}
    std::size_t body_length() const { return m_body_length;}
    
    //function
    Message();
    void body_length(std::size_t);
    bool decode_header();
    void encode_header();

    private:
    char m_data[head_length + max_body_length];
    std::size_t m_body_length;
};






#endif /*_MESSAGE_HPP_*/